package com.shj.shiro.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shj.shiro.mapper.UserMapper;
import com.shj.shiro.model.User;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;

	public boolean isValidUser(String uid, String pwd) {
		User user = userMapper.findByUser(uid, pwd);
		return user == null;
	}

	public boolean isUsernameExist(String uid){
		User user = userMapper.findByUserId(uid);
		return user != null;
	}

	public boolean isMobilNumExist(String mobilNum){
		int i = userMapper.findByMobileNum(mobilNum);
		return i > 0;
	}
	
	public User findByUserId(String uid){
		return userMapper.findByUserId(uid);
	}
	
	public void createUser(User user){
		userMapper.insert(user);
	}

}
